<%@ page language="java" contentType="text/html;charset=GB2312"
	pageEncoding="UTF-8"%>
<%@page import="java.io.*"%>
<%@page import="java.sql.*"%>
<%
	Connection conn = null;
	try {
		Class.forName("oracle.jdbc.driver.OracleDriver");
		conn = DriverManager.getConnection(
				"jdbc:oracle:thin:@192.168.253.201:1521:orcl", "jsdb",
				"ok");
		Statement stmt = conn.createStatement();
		String id = request.getParameter("aid").toString();
		String sql = "select data from st_attachment where aid = '"
				+ id + "'";
		InputStream in = null;
		ResultSet rs = stmt.executeQuery(sql);
		if (rs.next()) {
			in = rs.getBinaryStream("data");
		}
		OutputStream toClient = response.getOutputStream();
		response.reset();
		response.setContentType("application/msword;charset=GB2312");
		int len = 10 * 1024 * 1024;
		byte[] P_Buf = new byte[len];
		int i;
		while ((i = in.read(P_Buf)) != -1) {
			toClient.write(P_Buf, 0, i);
		}
		in.close();
		toClient.flush();
		toClient.close();
		try {
			if (conn != null)
				conn.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	} catch (Exception e) {
		System.out.println("出现异常: " + e.getMessage());
	}
%>